package com.airbat.prize.common.enums;

import com.airbat.prize.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 预警四色等级
 */
@Getter
@AllArgsConstructor
public enum ColorLevelEnum implements IntArrayValuable {

    RED(1, "红色"),
    ORANGE(2, "橙色"),
    YELLOW(3, "黄色"),
    GREEN(4, "绿色");

    /**
     * 值
     */
    private final Integer value;
    /**
     * 名称
     */
    private final String name;

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ColorLevelEnum::getValue).toArray();

    @Override
    public int[] array() {
        return ARRAYS;
    }

    public static ColorLevelEnum valueOf(Integer value) {
        for (ColorLevelEnum colorLevelEnum : values()) {
            if (colorLevelEnum.getValue().equals(value)) {
                return colorLevelEnum;
            }
        }
        return null;
    }
}
